import { ref, onMounted, onUnmounted } from 'vue'
/* 
获取屏幕尺寸
*/
export default function hookWindowResize() {
  const innerWidth = ref(0 || window.innerWidth)
  const innerHeight = ref(0 || window.innerHeight)

  const handleResize = () => {
    innerWidth.value = window.innerWidth;
    innerHeight.value = window.innerHeight;
  };

  onMounted(() => {
    window.addEventListener("resize", handleResize);
  })

  onUnmounted(() => {
    document.removeEventListener('resize', handleResize)
  })

  return { innerWidth, innerHeight }
}